package com.parkinglot.management.util;

import com.baidu.aip.ocr.AipOcr;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
public class DiscernCarNum {
    @Autowired
    AipOcr aipOcr;

    public String getCarNumFromImg(String imgPath) {

        JSONObject res = aipOcr.plateLicense(imgPath, new HashMap<String, String>());
        JSONObject words_result = (JSONObject) res.get("words_result");
        return words_result.get("number").toString();
    }
}
